package fr.mywiki.view.web.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;

import fr.mywiki.business.navigation.NavigationManager;

public class SpacesAction extends DispatchAction {
	/**
	 * Modifies the space of the current session. The identifier of the next space to display is
	 * contained in the request attribute "spaceName".
	 */
	public ActionForward changeSpace(ActionMapping mapping, ActionForm actionForm,
			HttpServletRequest request, HttpServletResponse arg3) {
		String newSpace = (String) ((DynaActionForm) actionForm).get("spaceName"); 
		
		NavigationManager.setCurrentSpace(request.getSession(), newSpace);
		return mapping.findForward(newSpace);
	}
}
